﻿///Nokia QWERTY-Keboard Editor - tool for editing qwerty-keyboards on Symbian^1 - Symbian^3 devices
///Copyright (C) 2010-2011  Kalashnikov I.N.
///
///This program is free software; you can redistribute it and/or
///modify it under the terms of the GNU General Public License
///as published by the Free Software Foundation; either version 2
///of the License, or (at your option) any later version.
///
///This program is distributed in the hope that it will be useful,
///but WITHOUT ANY WARRANTY; without even the implied warranty of
///MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
///GNU General Public License for more details.
///
///You should have received a copy of the GNU General Public License
///along with this program; if not, write to the Free Software
///Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

using System;
using System.Windows.Forms;

namespace Nokia_QWERTY_Keyboard_Editor
{
    public partial class EditSymbol : Form
    {
        Action<string> _action;

        public EditSymbol(string currentSymbol, Action<string> applyAction)
        {
            InitializeComponent();
            this.label1.Text += currentSymbol;
            _action = applyAction;
        }
        private void Apply()
        {
            _action(symbolText.Text);
            this.Close();
        }
        private void applyButton_Click(object sender, EventArgs e)
        {
            Apply();
        }
        private void symbolText_TextChanged(object sender, EventArgs e)
        {
            if (symbolText.Text.Length > 1)
                symbolText.Text = symbolText.Text.Substring(0, 1);
        }
        private void symbolText_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (int)Keys.Enter)
                Apply();
        }
    }
}